/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.opu.vcforms.template;

import org.opu.vcforms.template.bean.Content;

/**
 *
 * @author yura
 */
public class ContentDelegator implements Delegator {
    public static final String CONTENTTYPE = "content-type";
    public static final String TEXT = "text";

    private Content content = new Content();

    @Override
    public void setProperty(String key, String value) {
        if (CONTENTTYPE.equals(key)){
            Validator.assertIsOneOf("Can't init content data", value,
                    Content.TYPE_DATABASE, Content.TYPE_SYSTEM_SETTINGS,
                    Content.TYPE_USER_SETTINGS);
            content.setType(value);
        } else {
            content.set(key, value);
        }
    }

    public Content getContent() {
        return content;
    }

    @Override
    public void setText(String text) {
        content.set(TEXT, text);
    }

}
